home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snip1292.zip / RMTRAIL.C < prev    next >
C/C++ Source or Header  |  1992-12-26  |  608b  |  32 lines

  1. /*
  2. **  Originally published as part of the MicroFirm Function Library
  3. **
  4. **  Copyright 1986, S.E. Margison
  5. **  Copyright 1989, Robert B.Stout
  6. **
  7. **  Subset version released to the public domain, 1991
  8. **
  9. **  remove trailing whitespace from a string
  10. */
  11.  
  12. #include <string.h>
  13. #include <ctype.h>
  14.  
  15. #define NUL '\0'
  16.  
  17. char *rmtrail(char *str)
  18. {
  19.       int i;
  20.  
  21.       if (0 != (i = strlen(str)))
  22.       {
  23.             while (--i >= 0)
  24.             {
  25.                   if (!isspace(str[i]))
  26.                         break;
  27.             }
  28.             str[++i] = NUL;
  29.       }
  30.       return str;
  31. }
  32.